package com.metacube.metaconnect.model;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class SignUpStep1Form extends ActionForm {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String email;
	private String name;
	private String password;
	private String confirm_password;
	private String gender = "Male";

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getConfirm_password() {
		return confirm_password;
	}

	public void setConfirm_password(String confirm_password) {
		this.confirm_password = confirm_password;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errorList = new ActionErrors();
		request.setAttribute("emailId", email);
		if (name.equals(""))
			errorList.add("name", new ActionMessage("MetaConnect.error.name"));
		if (password.equals(""))
			errorList.add("password", new ActionMessage(
					"MetaConnect.error.password"));
		else if (password.length() < 6)
			errorList.add("password", new ActionMessage(
					"MetaConnect.error.passwordLength"));
		else if (confirm_password.equals(""))
			errorList.add("confirm_password", new ActionMessage(
					"MetaConnect.error.confirm_password"));
		else if (!password.equals(confirm_password))
			errorList.add("confirm_password", new ActionMessage(
					"MetaConnect.error.passwordMatch"));
		if (gender == null)
			errorList.add("gender", new ActionMessage(
					"MetaConnect.error.gender"));
		return errorList;
	}

	public void reset(ActionMapping mapping, HttpServletRequest request) {
		name = null;
		password = null;
		confirm_password = null;
		gender = null;
	}
}
